package util;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

public class IoUtil {
    public static void writer(List<String> list,String filePath) {
        try {
            if (list == null) {
                return;
            }
            //String filePath = "D:\\jdbc\\1111.md";
            File file = new File(filePath);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fileWriter = new FileWriter(file, true);
            list.forEach(e -> {
                try {
                    fileWriter.write(e + "\n");
                } catch (IOException ioException) {
                    ioException.printStackTrace();
                }
            });
            fileWriter.flush();
            fileWriter.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
